package com.cj.service.impl;


import com.cj.dao.ClassDao;
import com.cj.dao.DormgradeDao;
import com.cj.po.Classes;
import com.cj.po.Dormgrade;
import com.cj.po.PageInfo;
import com.cj.po.Student;
import com.cj.service.ClassService;
import com.cj.service.DormgradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;

import java.util.List;

@Service("dormgradelService")
@Transactional

public class Dormgradelmpl implements DormgradeService {
    @Autowired
    private DormgradeDao dormgradeDao;
//    @Override
//    public PageInfo<Student> findPageInfo(Integer c_classid, String c_classname, String c_counsellor, Integer pageIndex, Integer pageSize) {
//        return null;
//    }
//    @Override
//    public pageInfo<Dormgrade> findDormitory(Integer d_id);
    @Override
    public PageInfo<Dormgrade> findPageInfo(Integer d_id, Integer s_dormitoryid,
                                            String d_dormbuilding, Integer d_bed, String a_name, Integer  pageIndex, Integer pageSize) {
        PageInfo<Dormgrade> pi = new PageInfo<>();
        pi.setPageIndex(pageIndex);
        pi.setPageSize(pageSize);
        //获取总条数
        Integer totalCount = dormgradeDao.totalCount(d_id,s_dormitoryid,d_dormbuilding,d_bed,a_name,pageIndex,pageSize);
        if (totalCount>0){
            pi.setTotalCount(totalCount);
            //每一页显示学生信息数
            //currentPage = (pageIndex-1)*pageSize  当前页码数减1*最大条数=开始行数
            List<Dormgrade> dormgradeList =	dormgradeDao.getDormgradeList(d_id,s_dormitoryid,d_dormbuilding,d_bed,a_name,pageIndex,pageSize,
                    (pi.getPageIndex()-1)*pi.getPageSize(),pi.getPageSize());

            pi.setList(dormgradeList);
    }
        return pi;
    }


    @Override
    public int deleteStudent(Integer s_id) {
        return 0;
    }

    @Override
    public int addStudent(Student student) {
        return 0;
    }

    @Override
    public int updateStudent(Student student) {
        return 0;
    }

    @Override
    public Student findStudentById(Integer s_id) {
        return null;
    }

    @Override
    public List<Student> getAll() {
        return null;
    }

    @Override
    public Dormgrade findDormitory(Integer d_id) {
        return null;
    }

    @Override
    public PageInfo<Dormgrade> findClassStudent(Integer d_id) {
        return null;
    }

    @Override
    public PageInfo<Dormgrade> findPageInfo(Integer d_id, Integer s_dormitoryid, String d_dormbuilding, Integer d_bedtotal, Integer d_bed, String a_name) {
        return null;
    }
}
